ed68ec6ac437d70d9c8c28f553d472d0ed9cf96e,opennms-provision/opennms-provision-api/src/main/java/org/opennms/netmgt/provision/support/ConnectionFactory.java,ConnectionFactory,connect,#SocketAddress#IoSessionInitializer#,134

Before Change


            } catch (IllegalStateException e) {
                LogUtils.debugf(this, "Caught exception, retrying: %s", e);
                synchronized (m_connector) {
                    m_connector.dispose();
                    m_connector = getSocketConnector();
                    try { Thread.sleep(10); } catch (InterruptedException ex) {}
                }

After Change


        }
        for (int retries = 0; retries < s_connectionExecutionRetries; retries++) { 
            synchronized (m_connectorMutex) {
                if (m_connector == null) {
                    // Sanity check for null connector instance
                    LogUtils.warnf(this, "Found a null NioSocketConnector, creating a new one");
                    m_connector = getSocketConnector(m_timeout);
                    continue;
                } else if (m_connector.isDisposed() || m_connector.isDisposing()) {
                    /*
                     * There appears to be a bug in MINA that allows newly-created NioSocketConnectors
                     * to internally reference an executor that is already shutting down. We need to
                     * check for this state and recreate the connector if necessary.
                     * 
                     * @see http://issues.opennms.org/browse/NMS-4846
                     */
                    LogUtils.warnf(this, "Found a disposed NioSocketConnector, creating a new one");
                    m_connector = getSocketConnector(m_timeout);
                    continue;
                }
                try {
                    /*
                     * Use the 3-argument call to connect(). If you use the 2-argument version without
                     * the localhost port, the call will end up doing a name lookup which seems to fail
                     * intermittently in unit tests.
                     *
                     * @see http://issues.opennms.org/browse/NMS-5309
                     */
                    return m_connector.connect(remoteAddress, localAddress, init);
                } catch (Throwable e) {
                    LogUtils.debugf(this, e, "Caught exception on factory %s, retrying: %s", this, e);
                    m_connector.dispose(true);
                    /*
                    while(!m_connector.isDisposed()) {
                        try { Thread.sleep(10); } catch (InterruptedException ex) {}